package com.example.controller;

import com.example.entity.FoodsRecipe;
import com.example.service.FoodsRecipeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/foods")
public class FoodsController {

    @Autowired
    private FoodsRecipeService foodsRecipeService;

    @GetMapping("/list")
    public String listFoods(Model model) {
        List<FoodsRecipe> recipes = foodsRecipeService.getAllRecipes();
        model.addAttribute("recipes", recipes);
        return "foods/list"; // 对应您的商品列表JSP页面
    }
}